package com.power.mock.simple;

import com.google.inject.Inject;
import com.power.mock.User;
import com.power.mock.dto.UserQueryDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author wangjianxin01
 */
public class UserService {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Inject
    private UserDAO userDAO;

    public void saveUser(User user){
        logger.info("in method UserService.saveUser(User user), user = {}", user);
        userDAO.saveUser(user);
    }

    public User getUser(String userName) {
        logger.info("in method UserService.getUser(String userName), userName = {}", userName);
        return userDAO.getUser(userName);
    }


    public List<User> listUser(String userName, Integer age) {
        logger.info("in method UserService.listUser(String userName, Integer age), userName = {}, age = {}" ,userName, age );
        UserQueryDTO userQueryDTO = new UserQueryDTO();
        userQueryDTO.setUserName(userName);
        userQueryDTO.setAge(age);
        return userDAO.listUser(userQueryDTO);
    }

}
